//蜂鸣器控制模块
module beep_ctrl(
	input 			sys_clk,
	input			sys_rst_n,
	
	input			key_flag,
	input			key_val,
	output	reg		beep
);

always @(posedge sys_clk or negedge sys_rst_n)	begin
	if(!sys_rst_n)
		beep <= 1'b0;	//初始状态为不鸣叫
	else	begin
		if(key_flag & (~key_val))
			beep <= ~beep;
		else	
			beep <= beep;
	end	
end

endmodule